package lormi.meipin.controller.api;

import lormi.meipin.common.Result;
import lormi.meipin.controller.BaseController;
import lormi.meipin.dto.ExpectWorkDto;
import lormi.meipin.exception.LMException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 人才期望工作设置
 * */
@RestController
@RequestMapping(value="v2/expectwork/",method=RequestMethod.POST,produces = "application/json; charset=utf-8")
public class ExpectWorkController extends BaseController{

	/**
	 * 添加或修改期望工作
	 * @throws Exception 
	 * @Param userid 用户ID
	 * @Param usertype 用户类型
	 * @Param positionclass 职位Id
	 * @Param salary 期望薪资
	 * @Param hostcity 期望工作地点
	 * */
	@RequestMapping("")
	public String expectwork(@Valid ExpectWorkDto expectWorkDto,BindingResult result) throws Exception{
		checkResult(result);
		
		expectWorkService.addOrEditExpectWork(expectWorkDto);
		return Result.success();
	}
	
	/**
	 * 获取期望工作
	 * @Param userid 用户ID
	 * @Param usertype 用户类型
	 * */
	@RequestMapping("get")
	public String getOne(Integer userid) throws LMException{
		
		return Result.success(expectWorkService.getExpectWork(userid));
	}
	
}
